import { fetcher } from '@/src/utils/fetcher'
import { getTranslations } from 'next-intl/server'
import { cookies } from 'next/headers'
import Hero from '../../components/hero'
import Breadcrumb from '../../components/breadcrumb'
import AnchorTitle from '../../components/anchor-title'
import ScrollToTop from '../../components/scroll-to-top'

interface LayoutProps {
  children: React.ReactNode
}

const Layout: React.FC<LayoutProps> = async (props) => {
  const { children } = props
  const [t, bt] = await Promise.all([
    getTranslations('contact'),
    getTranslations('breadcrumb'),
  ])
  const cookieStore = cookies()
  const sliders = await fetcher<Slider[]>('/api/index/adList?type=contact', {
    cookieStore,
  })
  return (
    <main>
      <ScrollToTop />
      <Hero sliders={sliders} />
      <div className='px-[0.9375rem] lg:px-0 lg:max-w-[960px] lg:mx-auto 2xl:max-w-[1200px]'>
        {/* 面包屑 */}
        <div className='hidden lg:block'>
          <div className='h-8 2xl:h-12' />
          <Breadcrumb
            items={[
              { label: bt('home'), path: '/' },
              { label: bt('contact'), active: true },
            ]}
          />
        </div>
        <div
          id='contactUs'
          className='h-[1.875rem] lg:h-[2.1875rem] 2xl:h-[3.28125rem]'
        />
        {/* 公司简介 START */}
        <AnchorTitle title={t('contactUsForWinWinCooperation')} />
        <div className='h-[0.9375rem] lg:h-[2.125rem]' />
        {children}
      </div>
    </main>
  )
}

export default Layout
